<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('教务课程列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>课程名称：</label>
                            <input type="text" name="name"/>
                        </li>
                        <li>
                            <label>课程类别：</label>
                            <input type="text" name="category"/>
                        </li>
                        <li>
                            <label>科目：</label>
                            <input type="text" name="subject"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="teaching:course:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="teaching:course:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="teaching:course:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="teaching:course:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('teaching:course:edit')}]];
    var removeFlag = [[${@permission.hasPermi('teaching:course:remove')}]];
    var folderFlag = [[${@permission.hasPermi('teaching:course:folder')}]];
    var prefix = ctx + "teaching/course";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "教务课程",
            columns: [{
                checkbox: true
            },
                {
                    field: 'courseId',
                    title: '主键ID',
                    visible: false
                },
                {
                    field: 'preName',
                    title: '课程前缀',
                    visible: false
                },
                {
                    field: 'name',
                    title: '课程名称',
                    formatter: function (value, row, index) {
                        return '<a href="javascript:void(0)" onclick="detail(\'' + row.courseId + '\')">' + value + '</a>';
                    }
                },
                {
                    field: 'category',
                    title: '课程类别'
                },
                {
                    field: 'subject',
                    title: '科目'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.courseId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.courseId + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + folderFlag + '" href="javascript:void(0)" onclick="folder(\'' + row.courseId + '\')"><i class="fa fa-bars"></i>目录</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    /*课程-目录*/
    function folder(courseId) {
        var url = ctx + 'teaching/folder/?courseId=' + courseId;
        $.modal.openTab("课程目录", url);
    }

    function detail(courseId) {
        var url = ctx + 'teaching/course/detail/' + courseId;
        $.modal.openTab("课程列表", url);
    }
</script>
</body>
</html>
